package TimeSqueeze.storage;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;

import TimeSqueeze.common.TaskInterface;

public class WriteToFile {
	private String fileName = "TimeSqueezeSave.txt";
	// private boolean isOverwrite = true;
	
	public ArrayList<TaskInterface> untimedTasks = new ArrayList<TaskInterface>();
    public ArrayList<TaskInterface> deadlineTasks = new ArrayList<TaskInterface>();
    public ArrayList<TaskInterface> timedTasks = new ArrayList<TaskInterface>();
	
	public WriteToFile(ArrayList<TaskInterface> uTasksIn, ArrayList<TaskInterface> dTasksIn, ArrayList<TaskInterface> tTasksIn) {
		untimedTasks = uTasksIn;
		deadlineTasks = dTasksIn;
		timedTasks = tTasksIn;
	}
	
	public void saveToFile() throws FileNotFoundException {
		PrintWriter writeFile = new PrintWriter(fileName);
		
		for (int i=0; i<untimedTasks.size(); i++) {
			writeFile.println(untimedTasks.get(i).printContents());
		}
		writeFile.println("!");
		
		for (int i=0; i<deadlineTasks.size(); i++) {
			writeFile.println(deadlineTasks.get(i).printContents());
		}
		writeFile.println("!");
		
		for (int i=0; i<timedTasks.size(); i++) {
			writeFile.println(timedTasks.get(i).printContents());
		}
		writeFile.println("!");
		writeFile.close();
		
	}
	
	public String getFileName() {
		return fileName;
	}
	
	public void setFileName(String inputFileName) {
		fileName = inputFileName;
	}

}
